﻿Imports BibliotecaClasesTests.GestionTest
Imports System.IO
Public Class frmPrincipal

    Private Sub frmPrincipal_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load


        Dim lista As List(Of String) = miGestionTest.BuscaTest

        For Each archivo In lista
            cboListaTests.Items.Add(archivo)
        Next
        'For Each misArchivo In Directory.GetFiles("C:\Users\PC\Documents\Visual Studio 2010\Projects\SolutionTests\BibliotecaClasesTests\bin\Debug\Ficheros")
        '    Dim misArch() As String = misArchivo.Split("\")

        '    lstTests.Items.Add(misArch(misArch.Length - 1))
        'Next

    End Sub

    
    Private Sub btnCrearTema_Click(sender As System.Object, e As System.EventArgs) Handles btnCrearTema.Click
        frmCrearTema.Show()

    End Sub

    Private Sub btnSalir_Click(sender As System.Object, e As System.EventArgs) Handles btnSalir.Click
        Me.Close()
    End Sub

    Private Sub cboListaTests_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboListaTests.Click
        cboListaTests.Items.Clear()
        Dim lista As List(Of String) = miGestionTest.BuscaTest

        For Each archivo In lista

            cboListaTests.Items.Add(archivo)
        Next
    End Sub

    Private Sub btnEliminarTema_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEliminarTema.Click
        miGestionTest.EliminarFichero(cboListaTests.SelectedItem)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResponderTest.Click
        grpPreguntas.Visible = True
        Dim cont As Integer = 0
        Dim nombreTest As String = cboListaTests.SelectedItem
        fich = New StreamReader(My.Application.Info.DirectoryPath & "\Ficheros\" & nombreTest)
        Dim x As Integer = 20
        Dim y As Integer = 36
        Dim lista As List(Of String) = miGestionTest.BuscaTest
        Do Until fich.EndOfStream ' Fin del fichero (boolean)
            Dim caja As New TextBox
            Dim box As New CheckBox

            box.Visible = True
            caja.Visible = True

            box.Size = New Size(50, 20)
            caja.Size = New Size(400, 20)

            box.Enabled = True
            caja.Enabled = True

            box.Location = New Point(x + 500, y)
            caja.Location = New Point(x, y)

            box.Name = "box" & cont
            caja.Name = "txt" & cont
            'boton.Name = "btn" & cont ' varios controles en tiempo de ejecución pueden compartir el nombre
            ''AddHandler caja.KeyPress, AddressOf txt_KeyPress ' Ejecturá el subPrograma txt_KeyPress cuando se pulse una tecla sobre la caja de texto que estamos creando
            ' el objeto nuevo creado aún está en memoria
            Me.Controls.Add(caja)
            Me.Controls.Add(box)

            Me.grpPreguntas.Controls.Add(box)
            Me.grpPreguntas.Controls.Add(caja)

            misControles.Add(box)
            misControles.Add(caja)


            Dim datos() As String
            Dim linea As String

            linea = fich.ReadLine
            datos = linea.Split("*")

            'Personas.Add(New Persona(datos(0), Integer.Parse(datos(1))))
            caja.Text = datos(0)






            y += caja.Height + 3
            cont += 1
        Loop
    End Sub

    Private Sub cboListaTests_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboListaTests.SelectedIndexChanged
        grpBotones.Visible = True
    End Sub

    Private Sub btnAnadirPreguntas_Click(sender As System.Object, e As System.EventArgs) Handles btnAnadirPreguntas.Click

    End Sub
End Class